package com.mask.mr;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * KEYIN: 原始数据经过转换后的key1 -- 字符串
 * VALUEIN：原始数据经过转换后的value1 -- 整数
 * KEYOUT：经过Map程序处理后的数据key2 -- 字符串
 * VALUEOUT：经过map处理后的数据value2 -- 整数
 */
public class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    protected void map(LongWritable key, Text value, Mapper.Context context)
        throws IOException, InterruptedException{
        String line = value.toString();
        String[] words = line.split("\\|");
        for(String word : words){
            context.write(new Text(word), new IntWritable(1));
        }
    }
}